using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace WebCrawlerTools.form
{
    public enum HElementType
    {
        TEXT,
        SELECT,
        CHECKBOX,
        RADIO,
        FORM,
        HIDDEN,
        UNKNOW,
    }
    public class HElement
    {
        private string name;
        private string id;
        private string val;
        private HElementType type;
    
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }

        public string ID
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        public string Val
        {
            get
            {
                return val;
            }
            set
            {
                val = value;
            }
        }

        /// <summary>
        /// </summary>
        public HElementType Type
        {
            get
            {
                return type;
            }
            set
            {
                type = value;
            }
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("[Type:" + type+"]");
            sb.Append("[Name:" + name + "]");
            sb.Append("[Id:" + id + "]");
            sb.Append("[Value:" + val + "]");
            return sb.ToString();
        }
    }
    public class HForm : HElement
    {
        private ArrayList elements;
        public HForm()
        {
            this.Type = HElementType.FORM;
            elements = new ArrayList();
        }

        public ArrayList Elements
        {
            get
            {
                return elements;
            }
            set
            {
                elements = value;
            }
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("Form:");
            sb.Append("[Type:" + Type + "]");
            sb.Append("[Name:" + Name + "]");
            sb.Append("[Id:" + ID + "]");
            sb.Append(Environment.NewLine);
            foreach (HElement hele in elements)
            {
                sb.Append(hele.ToString());
                sb.Append(Environment.NewLine);
            }
            return sb.ToString();
        }
    }
    public class HInputCheck : HElement
    {
        public HInputCheck()
        {
            this.Type = HElementType.CHECKBOX;
        }
    }
    public class HInputText : HElement
    {
        public HInputText()
        {
            this.Type = HElementType.TEXT;
        }
    }
    public class HSelectOne : HElement
    {
        public HSelectOne()
        {
            this.Type = HElementType.SELECT;
        }
    }
    public class HInputRadio : HElement
    {
        public HInputRadio()
        {
            this.Type = HElementType.RADIO;
        }
    }
}
